#include "GY_Bezel.h"
#include <QDebug>
#include "Graphics/GY_GraphicsReflection.h"

GY_Bezel::GY_Bezel(const QString &guid, QGraphicsItem *parent)
    : GY_ContainerTransform(guid,this, parent)
{
    initializationPropertyInfo();
    this->setCenterPointF(m_PropertyInfoMap["Position"].propertyValue.toPointF());
    //设置各部分图形
    setBackground();
    setRight();
    setBottom();
    setTopLeft();
    setBezelColors();
    setFocusOutline();
    setContainerEditPointF();
    //更新自身属性，刷新图形数据
    updateSelfProperty();
}

GY_Bezel::~GY_Bezel()
{

}

void GY_Bezel::setContainerEditPointF()
{
    QMap<QVariant,QPointF> editPoints = {
        {"Point",m_PropertyInfoMap["Size"].propertyValue.toPointF()}
        ,{"Depthp",QPointF(m_PropertyInfoMap["Depth"].propertyValue.toFloat(),m_PropertyInfoMap["Depth"].propertyValue.toFloat())}
    };
    this->setEditPointF(editPoints);
}

GY_Object *GY_Bezel::copyItem(const QString &guid)
{
    if(getUserData(GY_ENUM::IsCopy) == 1) {
        GY_Object *tmp;
        this->copyItemSig(&tmp);
        //更新copyItem属性列表
        QMap<QString,GY_PropertyInfo>::Iterator iterProperty = m_PropertyInfoMap.begin();
        while (iterProperty != m_PropertyInfoMap.end()) {
            if(((iterProperty.value().updateType)&PointOfRelative) == PointOfRelative) {
                tmp->updateProperty(iterProperty.key(), submittingPropertyValues(iterProperty.value().updateType,iterProperty.value().propertyValue,this));
            }else if(((iterProperty.value().updateType)&NotUpdate) == NotUpdate){
                ++iterProperty;
                continue;
            }else {
                tmp->updateProperty(iterProperty.key(), iterProperty.value().propertyValue);
            }
            ++iterProperty;
        }
        return tmp;
    }
    GY_Object* pObj;
    if(guid.isEmpty()) {
        pObj = (GY_Object*)GY_GraphicsReflection::getInstance()->newInstanceObjectClass(this->metaObject()->className(),this->getGuid()+"-"+QString::number(m_MyGuid));
        m_MyGuid++;
    }else {
        pObj = (GY_Object*)GY_GraphicsReflection::getInstance()->newInstanceObjectClass(this->metaObject()->className(),guid);
    }
    if(pObj == nullptr) {
        qDebug()<<this->getGuid()<<"isEmpty";
        return nullptr;
    }
    QMap<QString,GY_PropertyInfo>::Iterator iter = m_PropertyInfoMap.begin();
    while (iter != m_PropertyInfoMap.end()) {
        if(((iter.value().updateType)&PointOfRelative) == PointOfRelative) {
            pObj->updateProperty(iter.key(), submittingPropertyValues(iter.value().updateType,iter.value().propertyValue,this));
        }else if(((iter.value().updateType)&NotUpdate) == NotUpdate){
            ++iter;
            continue;
        }else {
            pObj->updateProperty(iter.key(), iter.value().propertyValue);
        }
        ++iter;
    }
    connect(pObj,&GY_Object::copyItemSig,this,&GY_Object::originalVersion);
    pObj->setUserData(GY_ENUM::IsCopy, QVariant::fromValue(1));
    return pObj;
}

bool GY_Bezel::addItem(GY_Object *)
{
    return false;
}

bool GY_Bezel::removItem(const QString &)
{
    return false;
}

bool GY_Bezel::removItem(const GY_Object *)
{
    return false;
}

void GY_Bezel::setBackground()
{
    m_pBackground = new GY_GraphicsRectItem("Background",this);
    m_pBackground->setObjName("Background");
    m_pBackground->updateProperty("IsVisible",true);
    m_pBackground->updateProperty("IsOutlined",false);
    m_pBackground->updateProperty("IsFilled",true);
    m_pBackground->updateProperty("IsAntialiased",false);
    m_pBackground->updateProperty("FillAttributes",false);
    m_pBackground->updateProperty("FillStyle",true);
    m_pBackground->updateProperty("FillColor",QColor(209,204,198));
    m_pBackground->updateProperty("PenColor",QColor(255,255,255));
    LineStyle ls;
    ls.width = 1;
    ls.cap = "butt";
    ls.join = "miter";
    ls.line = "FFFF";
    m_pBackground->updateProperty("LineStyle",QVariant::fromValue(ls));
    m_pBackground->updateProperty("Point1",QPointF(0,0));
    //自身属性和控制图形属性进行关联
    connect(this,&GY_Bezel::updatePropertyEvent,[=](const GY_Object*,const QString &propertyName,
            const QVariant &propertyValue,const PropertyType &) {
//        qDebug()<<propertyName<<propertyValue<<type;
        if(propertyName == "Size") {
            //自身属性控制图形属性
            m_pBackground->updateProperty("Point2",propertyValue);
        }
    });

    this->addToGroup(m_pBackground);
    m_pBackground->setAcceptHoverEvents(false);
    m_pBackground->setSelected(false);
}

void GY_Bezel::setFocusOutline()
{
    m_pFocusOutline = new GY_GraphicsRectItem("FocusOutline",this);
    m_pFocusOutline->setObjName("FocusOutline");
    m_pFocusOutline->updateProperty("IsVisible",true);
    m_pFocusOutline->updateProperty("IsFilled",false);
    m_pFocusOutline->updateProperty("IsAntialiased",false);
    m_pFocusOutline->updateProperty("FillAttributes",false);
    m_pFocusOutline->updateProperty("FillStyle",true);
    m_pFocusOutline->updateProperty("FillColor",QColor(255,255,255));
    m_pFocusOutline->updateProperty("PenColor",QColor(0,0,127));
    LineStyle ls;
    ls.width = 1;
    ls.cap = "butt";
    ls.join = "miter";
    ls.line = "FFFF";
    m_pFocusOutline->updateProperty("LineStyle",QVariant::fromValue(ls));
    connect(this,&GY_Bezel::updatePropertyEvent,[=](const GY_Object*,const QString &propertyName,
            const QVariant &propertyValue,const PropertyType &) {
        if(propertyName == "Size") {
            //size修改对应值改变
            qreal x = propertyValue.toPointF().x()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            qreal y = propertyValue.toPointF().y()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            m_pFocusOutline->updateProperty("Point2",QPointF(x,y));
        }else if(propertyName == "Focused") {
            //Focused修改对应值改变
            m_pFocusOutline->updateProperty("IsOutlined",propertyValue);
        }else if(propertyName == "Depth") {
            //Depth修改对应值改变
            m_pFocusOutline->updateProperty("Point1.X",propertyValue);
            if(m_PropertyInfoMap["ShowBottom"].propertyValue.toBool()) {
                m_pFocusOutline->updateProperty("Point1.Y",propertyValue);
            }else {
                m_pFocusOutline->updateProperty("Point1.Y",0);
            }
            qreal x = m_PropertyInfoMap["Size"].propertyValue.toPointF().x()-propertyValue.toFloat();
            qreal y = m_PropertyInfoMap["Size"].propertyValue.toPointF().y()-propertyValue.toFloat();
            m_pFocusOutline->updateProperty("Point2",QPointF(x,y));
        }else if(propertyName == "ShowBottom") {
            //ShowBottom修改对应值改变
            if(propertyValue.toBool()) {
                m_pFocusOutline->updateProperty("Point1.Y",m_PropertyInfoMap["Depth"].propertyValue.toFloat());
            }else {
                m_pFocusOutline->updateProperty("Point1.Y",0);
            }
        }
    });

    this->addToGroup(m_pFocusOutline);
    m_pFocusOutline->setAcceptHoverEvents(false);
    m_pFocusOutline->setSelected(false);
}

void GY_Bezel::setTopLeft()
{
    m_pTopLeft = new GY_GraphicsPolygon("TopLeft",this);
    m_pTopLeft->setObjName("TopLeft");
    m_pTopLeft->updateProperty("IsVisible",true);
    m_pTopLeft->updateProperty("IsOpen",false);
    m_pTopLeft->updateProperty("IsOutlined",false);
    m_pTopLeft->updateProperty("IsAntialiased",false);
    m_pTopLeft->updateProperty("FillAttributes",false);
    m_pTopLeft->updateProperty("FillStyle",true);
    m_pTopLeft->updateProperty("PenColor",QColor(255,255,255));
    LineStyle ls;
    ls.width = 1;
    ls.cap = "butt";
    ls.join = "miter";
    ls.line = "FFFF";
    m_pTopLeft->updateProperty("LineStyle",QVariant::fromValue(ls));
    m_pTopLeft->updateProperty("PtsArray.Size", 6);
    m_pTopLeft->updateProperty("PtsArray[0]",QPointF(0,0));
    m_pTopLeft->updateProperty("PtsArray[1]",QPointF(0,0));
    connect(this,&GY_Bezel::updatePropertyEvent,[=](const GY_Object*,const QString &propertyName,
            const QVariant &propertyValue,const PropertyType &) {
        if(propertyName == "Size") {
            //因为Size改变，图形绑定数据跟着变化
            m_pTopLeft->updateProperty("PtsArray[1].Y",propertyValue.toPointF().y());
            m_pTopLeft->updateProperty("PtsArray[2]",propertyValue);
            qreal x = propertyValue.toPointF().x()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            qreal y = propertyValue.toPointF().y()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            m_pTopLeft->updateProperty("PtsArray[3]",QPointF(x,y));
            m_pTopLeft->updateProperty("PtsArray[4].Y",y);
        }else if(propertyName == "Enabled") {

            m_pTopLeft->updateProperty("IsFilled",propertyValue);
        }else if(propertyName == "Depth") {

            qreal x = m_PropertyInfoMap["Size"].propertyValue.toPointF().x()-propertyValue.toFloat();
            qreal y = m_PropertyInfoMap["Size"].propertyValue.toPointF().y()-propertyValue.toFloat();
            m_pTopLeft->updateProperty("PtsArray[3]",QPointF(x,y));
            m_pTopLeft->updateProperty("PtsArray[4].X",propertyValue.toFloat());
            m_pTopLeft->updateProperty("PtsArray[4].Y",y);
            m_pTopLeft->updateProperty("PtsArray[5]",QPointF(propertyValue.toFloat(),propertyValue.toFloat()));
        }else if(propertyName == "Pressed") {

            if(propertyValue.toBool()) {
                m_pTopLeft->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[1]"].propertyValue.value<QColor>());
            }else {
                m_pTopLeft->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[0]"].propertyValue.value<QColor>());
            }
        }
    });

    this->addToGroup(m_pTopLeft);
    m_pTopLeft->setAcceptHoverEvents(false);
    m_pTopLeft->setSelected(false);
}

void GY_Bezel::setRight()
{
    m_pRight = new GY_GraphicsPolygon("Right",this);
    m_pRight->setObjName("Right");
    m_pRight->updateProperty("IsVisible",true);
    m_pRight->updateProperty("IsOpen",false);
    m_pRight->updateProperty("IsOutlined",false);
    m_pRight->updateProperty("IsAntialiased",false);
    m_pRight->updateProperty("FillAttributes",false);
    m_pRight->updateProperty("FillStyle",true);
    m_pRight->updateProperty("PenColor",QColor(255,255,255));
    LineStyle ls;
    ls.width = 1;
    ls.cap = "butt";
    ls.join = "miter";
    ls.line = "FFFF";
    m_pRight->updateProperty("LineStyle",QVariant::fromValue(ls));
    m_pRight->updateProperty("PtsArray.Size", 4);
    m_pRight->updateProperty("PtsArray[1]",QPointF(0,0));
    connect(this,&GY_Bezel::updatePropertyEvent,[=](const GY_Object*,const QString &propertyName,
            const QVariant &propertyValue,const PropertyType &) {
        if(propertyName == "Size") {

            qreal x = propertyValue.toPointF().x()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            qreal y = propertyValue.toPointF().y()-m_PropertyInfoMap["Depth"].propertyValue.toFloat();
            m_pRight->updateProperty("PtsArray[0].X",x);
            m_pRight->updateProperty("PtsArray[1].X",propertyValue.toPointF().x());
            m_pRight->updateProperty("PtsArray[2]",propertyValue);
            m_pRight->updateProperty("PtsArray[3]",QPointF(x,y));
        }else if(propertyName == "Enabled") {

            m_pRight->updateProperty("IsFilled",propertyValue);
        }else if(propertyName == "Depth") {

            qreal x = m_PropertyInfoMap["Size"].propertyValue.toPointF().x()-propertyValue.toFloat();
            qreal y = m_PropertyInfoMap["Size"].propertyValue.toPointF().y()-propertyValue.toFloat();
            m_pRight->updateProperty("PtsArray[0].X",x);
            m_pRight->updateProperty("PtsArray[0].Y",propertyValue.toFloat());
            m_pRight->updateProperty("PtsArray[3]",QPointF(x,y));
        }else if(propertyName == "Pressed") {

            if(propertyValue.toBool()) {
                m_pRight->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[0]"].propertyValue.value<QColor>());
            }else {
                m_pRight->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[1]"].propertyValue.value<QColor>());
            }
        }
    });

    this->addToGroup(m_pRight);
    m_pRight->setAcceptHoverEvents(false);
    m_pRight->setSelected(false);
}

void GY_Bezel::setBottom()
{
    m_pBottom = new GY_GraphicsPolygon("Bottom",this);
    m_pBottom->setObjName("Bottom");
    m_pBottom->updateProperty("IsVisible",true);
    m_pBottom->updateProperty("IsOpen",false);
    m_pBottom->updateProperty("IsOutlined",false);
    m_pBottom->updateProperty("IsAntialiased",false);
    m_pBottom->updateProperty("FillAttributes",false);
    m_pBottom->updateProperty("FillStyle",true);
    m_pBottom->updateProperty("PenColor",QColor(255,255,255));
    LineStyle ls;
    ls.width = 1;
    ls.cap = "butt";
    ls.join = "miter";
    ls.line = "FFFF";
    m_pBottom->updateProperty("LineStyle",QVariant::fromValue(ls));
    m_pBottom->updateProperty("PtsArray.Size", 4);
    m_pBottom->updateProperty("PtsArray[0]",QPointF(0,0));
    m_pBottom->updateProperty("PtsArray[1]",QPointF(0,0));
    connect(this,&GY_Bezel::updatePropertyEvent,[=](const GY_Object*,const QString &propertyName,
            const QVariant &propertyValue,const PropertyType &) {
        if(propertyName == "Size") {

            m_pBottom->updateProperty("PtsArray[1].X",propertyValue.toPointF().x());
            m_pBottom->updateProperty("PtsArray[2].X",propertyValue.toPointF().x()-m_PropertyInfoMap["Depth"].propertyValue.toFloat());
        }else if(propertyName == "Enabled") {

            if(propertyValue.toBool()&&m_PropertyInfoMap["ShowBottom"].propertyValue.toBool()) {
                m_pBottom->updateProperty("IsFilled",true);
            }else {
                m_pBottom->updateProperty("IsFilled",false);
            }
        }else if(propertyName == "ShowBottom") {

            if(propertyValue.toBool()&&m_PropertyInfoMap["Enabled"].propertyValue.toBool()) {
                m_pBottom->updateProperty("IsFilled",true);
            }else {
                m_pBottom->updateProperty("IsFilled",false);
            }
        }else if(propertyName == "Depth") {

            m_pBottom->updateProperty("PtsArray[2].X",m_PropertyInfoMap["Size"].propertyValue.toPointF().x()-propertyValue.toFloat());
            m_pBottom->updateProperty("PtsArray[2].Y",propertyValue.toFloat());
            m_pBottom->updateProperty("PtsArray[3].X",propertyValue.toFloat());
            m_pBottom->updateProperty("PtsArray[3].Y",propertyValue.toFloat());
        }else if(propertyName == "Pressed") {

            if(propertyValue.toBool()) {
                m_pBottom->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[0]"].propertyValue.value<QColor>());
            }else {
                m_pBottom->updateProperty("FillColor",m_pBezelColors->getPropertyMap()["Element[1]"].propertyValue.value<QColor>());
            }
        }
    });

    this->addToGroup(m_pBottom);
    m_pBottom->setAcceptHoverEvents(false);
    m_pBottom->setSelected(false);
}

void GY_Bezel::setBezelColors()
{
    //颜色组提供两种颜色
    m_pBezelColors = new GY_ColorArray("BezelColors",this);
    m_pBezelColors->setObjName("BezelColors");
    m_pBezelColors->updateProperty("Element.Size", 2);
    m_pBezelColors->updateProperty("Element[0]", QColor(242,242,242));
    m_pBezelColors->updateProperty("Element[1]", QColor(76,76,76));

    this->addToGroup(m_pBezelColors);
}

void GY_Bezel::updateSelfProperty()
{
    //初始化属性
    this->updateProperty("IsVisible", true);
    this->updateProperty("Position", QPointF(0,0));
    this->updateProperty("Size", QPointF(20,20));
    this->updateProperty("Depth", 4);
    this->updateProperty("Enabled", true);
    this->updateProperty("Pressed", false);
    this->updateProperty("ShowBottom", true);
    this->updateProperty("Focused", false);
}

void GY_Bezel::initializationPropertyInfo()
{
    GY_PropertyInfo ObjectName(this);
    ObjectName.propertyName = "ObjectName";
    ObjectName.propertyValue = QString();
    ObjectName.updateType = Update|OrdinaryAttributes;
    ObjectName.propertyType = QStringPropertyType;
    ObjectName.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateObjectName;
    m_PropertyInfoMap.insert("ObjectName",ObjectName);
    m_PropertyInfoMap[ObjectName.propertyName].setConnect();

    //位置
    GY_PropertyInfo positonPropertyInfo(this);
    positonPropertyInfo.propertyName="Position";
    positonPropertyInfo.propertyValue=QPointF(0,0);
    positonPropertyInfo.updateType = Update|MoveUpdate|PointOfRelative;
    positonPropertyInfo.propertyType = PointPropertyType;
    positonPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updatePosition;
    m_PropertyInfoMap.insert(positonPropertyInfo.propertyName,positonPropertyInfo);
    m_PropertyInfoMap[positonPropertyInfo.propertyName].setConnect();

    //更新点位置
    GY_PropertyInfo sizePropertyInfo(this);
    sizePropertyInfo.propertyName="Size";
    sizePropertyInfo.propertyValue=QPointF(50,50);
    sizePropertyInfo.updateType = Update|OrdinaryAttributes;
    sizePropertyInfo.propertyType = PointPropertyType;
    sizePropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateSize;
    m_PropertyInfoMap.insert(sizePropertyInfo.propertyName,sizePropertyInfo);
    m_PropertyInfoMap[sizePropertyInfo.propertyName].setConnect();

    GY_PropertyInfo pointPropertyInfo(this);
    pointPropertyInfo.propertyName="Point";
    pointPropertyInfo.propertyValue=QPointF(50,50);
    pointPropertyInfo.updateType = NotUpdate;
    pointPropertyInfo.propertyType = PointPropertyType;
    pointPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updatePoint;
    m_PropertyInfoMap.insert(pointPropertyInfo.propertyName,pointPropertyInfo);
    m_PropertyInfoMap[pointPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo DepthpPropertyInfo(this);
    DepthpPropertyInfo.propertyName="Depthp";
    DepthpPropertyInfo.propertyValue=QPointF(0,0);
    DepthpPropertyInfo.updateType = NotUpdate;
    DepthpPropertyInfo.propertyType = PointPropertyType;
    DepthpPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateDepthp;
    m_PropertyInfoMap.insert(DepthpPropertyInfo.propertyName,DepthpPropertyInfo);
    m_PropertyInfoMap[DepthpPropertyInfo.propertyName].setConnect();

    //隐藏
    GY_PropertyInfo isVisiblePropertyInfo(this);
    isVisiblePropertyInfo.propertyName="IsVisible";
    isVisiblePropertyInfo.propertyValue=true;
    isVisiblePropertyInfo.updateType = Update|OrdinaryAttributes;
    isVisiblePropertyInfo.propertyType = BoolPropertyType;
    isVisiblePropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateIsVisible;
    m_PropertyInfoMap.insert(isVisiblePropertyInfo.propertyName,isVisiblePropertyInfo);
    m_PropertyInfoMap[isVisiblePropertyInfo.propertyName].setConnect();

    GY_PropertyInfo DepthPropertyInfo(this);
    DepthPropertyInfo.propertyName="Depth";
    DepthPropertyInfo.propertyValue=3;
    DepthPropertyInfo.updateType = Update|OrdinaryAttributes;
    DepthPropertyInfo.propertyType = FloatPropertyType;
    DepthPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateDepth;
    m_PropertyInfoMap.insert(DepthPropertyInfo.propertyName,DepthPropertyInfo);
    m_PropertyInfoMap[DepthPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo EnabledPropertyInfo(this);
    EnabledPropertyInfo.propertyName="Enabled";
    EnabledPropertyInfo.propertyValue=true;
    EnabledPropertyInfo.updateType = Update|OrdinaryAttributes;
    EnabledPropertyInfo.propertyType = BoolPropertyType;
    EnabledPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateEnabled;
    m_PropertyInfoMap.insert(EnabledPropertyInfo.propertyName,EnabledPropertyInfo);
    m_PropertyInfoMap[EnabledPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo PressedPropertyInfo(this);
    PressedPropertyInfo.propertyName="Pressed";
    PressedPropertyInfo.propertyValue=true;
    PressedPropertyInfo.updateType = Update|OrdinaryAttributes;
    PressedPropertyInfo.propertyType = BoolPropertyType;
    PressedPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updatePressed;
    m_PropertyInfoMap.insert(PressedPropertyInfo.propertyName,PressedPropertyInfo);
    m_PropertyInfoMap[PressedPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo ShowBottomPropertyInfo(this);
    ShowBottomPropertyInfo.propertyName="ShowBottom";
    ShowBottomPropertyInfo.propertyValue=true;
    ShowBottomPropertyInfo.updateType = Update|OrdinaryAttributes;
    ShowBottomPropertyInfo.propertyType = BoolPropertyType;
    ShowBottomPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateShowBottom;
    m_PropertyInfoMap.insert(ShowBottomPropertyInfo.propertyName,ShowBottomPropertyInfo);
    m_PropertyInfoMap[ShowBottomPropertyInfo.propertyName].setConnect();

    GY_PropertyInfo FocusedPropertyInfo(this);
    FocusedPropertyInfo.propertyName="Focused";
    FocusedPropertyInfo.propertyValue=true;
    FocusedPropertyInfo.updateType = Update|OrdinaryAttributes;
    FocusedPropertyInfo.propertyType = BoolPropertyType;
    FocusedPropertyInfo.updatePropertyFun=(GY_PropertyInfo::UpdatePropertyFun)&GY_Bezel::updateFocused;
    m_PropertyInfoMap.insert(FocusedPropertyInfo.propertyName,FocusedPropertyInfo);
    m_PropertyInfoMap[FocusedPropertyInfo.propertyName].setConnect();
}

bool GY_Bezel::updatePosition(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    //setpos设置为父级坐标
    QPointF point = value.toPointF();
    if(this->parentItem()) {
        point = this->mapToParent(this->mapFromScene(value.toPointF()));
    }
    this->setPos(point);
    m_PropertyInfoMap[name].propertyValue=this->mapFromScene(value.toPointF());
    return true;
}

bool GY_Bezel::updateIsVisible(const QString &name, const QVariant &value)
{
    if(!value.canConvert<bool>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toBool();
    this->setVisible(value.toBool());
    return true;
}

bool GY_Bezel::updatePoint(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    m_PropertyInfoMap["Size"].propertyValue = this->mapFromScene(value.toPointF());
    this->setEditPointF(name,this->mapFromScene(value.toPointF()));
    return true;
}

bool GY_Bezel::updateSize(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue = value;
    this->setEditPointF("Point",(value.toPointF()));
    return true;
}

bool GY_Bezel::updateDepthp(const QString &name, const QVariant &value)
{
    if(!value.canConvert<QPointF>())
    {
        return false;
    }
    m_PropertyInfoMap["Depth"].propertyValue = this->mapFromScene(value.toPointF()).y();
    this->setEditPointF(name,QPointF(m_PropertyInfoMap["Depth"].propertyValue.toFloat(),m_PropertyInfoMap["Depth"].propertyValue.toFloat()));
    return true;
}

bool GY_Bezel::updateDepth(const QString &name, const QVariant &value)
{
    if(!value.canConvert<float>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toFloat();
    this->setEditPointF("Depthp",QPointF(value.toFloat(),value.toFloat()));
    return true;
}

bool GY_Bezel::updateEnabled(const QString &name, const QVariant &value)
{
    if(!value.canConvert<bool>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toBool();
    return true;
}

bool GY_Bezel::updatePressed(const QString &name, const QVariant &value)
{
    if(!value.canConvert<bool>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toBool();
    return true;
}

bool GY_Bezel::updateShowBottom(const QString &name, const QVariant &value)
{
    if(!value.canConvert<bool>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toBool();
    return true;
}

bool GY_Bezel::updateFocused(const QString &name, const QVariant &value)
{
    if(!value.canConvert<bool>())
    {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue=value.toBool();
    return true;
}


